home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8178 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  59 lines

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: memory allocation using malloc and free
  5. Date: 28 Feb 96 02:15:47 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.825473747@rscernix>
  8. References: <4gagll$5rc@bertrand.ccs.carleton.ca> <danpop.824767980@rscernix> <4gbqd7$1em@inet-nntp-gw-1.us.oracle.com> <4gd8ngINNp5i@keats.ugrad.cs.ubc.ca> <danpop.824952492@rscernix> <825456804snz@genesis.demon.co.uk>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. Lawrence Kirby <fred@genesis.demon.co.uk> writes:
  13.  
  14. >In article <danpop.824952492@rscernix> danpop@mail.cern.ch "Dan Pop" writes:
  15. >
  16. >>For this particular discussion, the limit is 32K - 1.  And no more than
  17. >>one object of this size.  (Actually the phrasing is a little bit silly,
  18. >>because it doesn't even guarantee that every program containing such an
  19. >>object can be compiled and run, it requires that at least one program 
  20. >>should be correctly translated):
  21. >
  22. >The wording may not guarantee much but it is not silly. All real systems
  23. >have memory limit on a running program. If the wording guaranteed that
  24. >every program containing such an object (and in the absense of other
  25. >violations) can be compiled and run I can show all implementations to be
  26. >non-conforming. All I have to do is write a program that allocates x lots
  27. >of, say, 10K blocks and then a 32K-1 block. For any system with limited
  28. >memory there will be a value of x at which this fails. I may have to perform
  29. >a lot of trial and error to find x and the value may vary from run to run
  30. >but sooner or later I will hit a run that fails.
  31.  
  32. OTOH, an implementation can reject a program containing a single object 
  33. of 10K and still claim conformance because there is one (and only one)
  34. program which contains a 32K-1 object which is correctly translated, and
  35. this program is:
  36.  
  37.     main()
  38.     {
  39.     static a[32767];
  40.     return 0;
  41.     }
  42.  
  43. which works simply because 'a' is optimized away.  This makes the
  44. 32K-1 guarantee useless (as well as the rest of the guarantees in the
  45. translation limits section).
  46.  
  47. A better wording should have been used.  For this particular limit, the
  48. standard could have said that the (maximum) sum of all the sizes of the
  49. objects in _any_ program should be at least 32K-1.  Such a wording would
  50. still guarantee an object of 32K-1 in any program, yet your trick wouldn't
  51. work.
  52.  
  53. Dan 
  54. --
  55. Dan Pop
  56. CERN, CN Division
  57. Email: danpop@mail.cern.ch 
  58. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  59.